package com.itheima.domain;

/**
 * @ClassName: Person
 * @Description: 定义问问题的人Person
 * @author: Yrd
 * @date: 2021-11-02 20:11
 */
public class Person implements CallBack {
    private String answerStr;
    private Genius genius;

    public Person(Genius genius) {
        this.genius = genius;
    }

    public void ask(){
        genius.answer(this);
    }

    public void askASyn(){
        System.out.println("创建新线程请教问题");
        new Thread(()->genius.answer(this)).start();
        System.out.println("新线程已启动");
    }

    //回调方法，给其他类对象调用的
    @Override
    public void callBack(String str) {
        System.out.println("收到答案："+str);
        this.answerStr = str;
    }

    public String getAnswerStr() {
        return answerStr;
    }

    public void setAnswerStr(String answerStr) {
        this.answerStr = answerStr;
    }

    public Genius getGenius() {
        return genius;
    }

    public void setGenius(Genius genius) {
        this.genius = genius;
    }
}
